package com.example.moban.view.dialog;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.AppCompatTextView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;


import com.example.moban.R;

import butterknife.BindView;

/**
 * @author yql
 * @date: 2018/10/12.
 */
public class IvTvDialog extends SimpleDialogFragment {

    @BindView(R.id.dialog_content_text)
    AppCompatTextView dialogTitleText;
    @BindView( R.id.dialog_top_img )
    ImageView alertIcon;

    private boolean isSuccess;
    private String title;

    @Override
    public void setContentView(@NonNull LayoutInflater inflater, FrameLayout contentView, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.iv_iv_dialog_layout, contentView, false);
        contentView.addView(view);
    }

    @Override
    public void initView(View view) {
        dialogTitleText.setText(title);
        if( isSuccess ){
            alertIcon.setImageResource( R.mipmap.icon_success );
        }else{
            alertIcon.setImageResource( R.mipmap.icon_fail );
        }
    }

    @Override
    public void initData() {

    }

    public void showDialog(FragmentManager manager, String title) {
        this.title = title;
        show(manager, TAG);
    }

    public void showDialog(FragmentManager manager, String title , boolean isSuccess ) {
        this.title = title;
        this.isSuccess = isSuccess;
        show(manager, TAG);
    }
}
